<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--360浏览器优先以webkit内核解析-->
    <title>若依介绍</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet"/>
    <link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet"/>
    <link href="../static/css/style.min.css" th:href="@{/css/style.min.css}" rel="stylesheet"/>
    <link href="../static/css/jinrishuju.css" th:href="@{/css/jinrishuju.css}" rel="stylesheet"/>
</head>
<body class="gray-bg" style="overflow-x: scroll">
<div class="ibox-content no-padding">
    <div class="panel-body">
        <div class="box3" th:if="${session.quanxian == '老板'}" style="overflow-y: hidden;overflow-x: hidden;">
            <div class="a" style="top: 3%;">本周销售数量排行</div>
            <div class="col-md-12" style="top: 9%;display: flex;padding: 0 0 0 0;">
                <div class="b" style="width: 10%;text-align: center">日期</div>
                <div class="b" style="width: 20%;text-align: center">单号</div>
                <div class="b" style="width: 20%;text-align: center">项目名称</div>
                <div class="b" style="width: 15%;text-align: center">业务员</div>
                <div class="b" style="width: 20%;text-align: center">产品名称</div>
                <div class="b" style="width: 12%;text-align: center">数量</div>
            </div>
            <div class="i" style="height: 3px;width: 98%;top:12%;left: 2%"></div>
            <div class="col-md-12" id="week2main"
                 style="position: absolute;top: 13%;padding: 0 0 0 0;height: 50%;overflow-y: scroll;overflow-x: hidden;">
            </div>

            <div class="a" style="top: 65%">最近销售单据</div>
            <div style="position: absolute;top: 71%;display: flex;padding: 0 0 0 0;" class="col-md-12">
                <div class="b" style="width: 10%;text-align: center">日期</div>
                <div class="b" style="width: 20%;text-align: center">单号</div>
                <div class="b" style="width: 20%;text-align: center">项目名称</div>
                <div class="b" style="width: 15%;text-align: center">业务员</div>
                <div class="b" style="width: 20%;text-align: center">产品名称</div>
                <div class="b" style="width: 12%;text-align: center">数量</div>
                <div class="b" style="width: 16%;text-align: center">是否已出库</div>
            </div>
            <div class="i" style="height: 3px;width: 98%;top:75%;left: 2%"></div>
            <div class="col-md-12" style="position: absolute;top: 76%;padding: 0 0 0 0;" id="last2xiaoshou">
            </div>

        </div>
        <div class="box1" th:if="${session.quanxian == '老板'}">
            <div class="col-md-12" id="TheToMonth">
                <div class="col-md-2"
                     style="padding-right: 0;font-size: 26px;padding-top: 2%;color: #ecae0e;width: 18%;">月营业额
                </div>
            </div>
            <div class="i" style="height: 3px;width: 95%;top:8%;left: 4%"></div>
            <div class="a">
                <div class="col-sm-2" style="padding-right: 0">日营业额</div>
                <div class="col-sm-10" style="font-size: 15px;color: black;">
                    <div class="col-sm-6">
                        <label class="col-sm-5 control-label" style="margin-top: 3px;">起始时间：</label>
                        <input class="col-sm-7" type="date" id="startDate"/>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-5 control-label" style="margin-top: 3px;">结束时间：</label>
                        <input class="col-sm-7" type="date" id="endDate"/>
                    </div>
                    <div class="col-sm-6">
                        <label class="col-sm-5 control-label" style="margin-top: 3px;">发货人：</label>
                        <input class="col-sm-7" type="text" id="yeWuYuan"/>
                    </div>
                    <div class="col-sm-2">
                        <button style="width: 100%;height: 100%;color: black;margin-left: 12px" onclick="riYingYeEReSelect(
                                                document.getElementById('startDate').value,
                                                document.getElementById('endDate').value,
                                                document.getElementById('yeWuYuan').value
                                            )">
                            筛选
                        </button>
                    </div>
                </div>
            </div>
            <div style="width: 100%;margin-top: 18%;font-size: 20px;color:black;height: auto;">
                <div class="col-sm-12">
                    <div class="col-sm-3" style="text-align: center;">汇总日期</div>
                    <div class="col-sm-3" style="text-align: center;">发货人</div>
                    <div class="col-sm-2" style="text-align: center;">成本汇总</div>
                    <div class="col-sm-2" style="text-align: center;">毛利</div>
                    <div class="col-sm-2" style="text-align: center;">销售总额</div>
                </div>
            </div>
            <div class="i" style="height: 3px;width: 95%;top:24%;left: 4%"></div>

            <div id="svgtest" style="width: 100%;margin-top: 24%;font-size: 20px;color: black;height: 77%;"></div>

        </div>
        <div class="box1" th:if="${session.quanxian == '跟单'}">
            <div class="a" style="top: 3%;">本周未出库单据</div>
            <!--            通知单图片，出库单号，项目名，两个配套类型，总金额-->
            <!--            <div style="position: absolute;display: flex;padding: 0 0 0 0;top: 10%;" class="col-md-12">-->
            <!--                <div class="b" style="width: 10%;text-align: center">日期</div>-->
            <!--                <div class="b" style="width: 20%;text-align: center">出库单号</div>-->
            <!--                <div class="b" style="width: 15%;text-align: center">项目名</div>-->
            <!--                <div class="b" style="width: 15%;text-align: center">商品名</div>-->
            <!--                <div class="b" style="width: 12%;text-align: center">配套五金</div>-->
            <!--                <div class="b" style="width: 12%;text-align: center">总金额</div>-->
            <!--                <div class="b" style="width: 12%;text-align: center">通知单</div>-->
            <!--            </div>-->
            <!--            <div class="i" style="height: 3px;width: 98%;top:14%;left: 1%"></div>-->
            <div id="weiChuFor" class="col-md-12 select-table table-striped"
                 style="position: absolute;top: 10%;padding: 0 0 0 0;">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th style="text-align: center;" data-field="xiadanriqi">
                            <div class="th-inner ">日期</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center;" data-field="chukudanhao">
                            <div class="th-inner ">出库单号</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center;" data-field="xiangmumingcheng">
                            <div class="th-inner ">项目名</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center;" data-field="shangpin">
                            <div class="th-inner ">商品名</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center; " data-field="wujinpeitao">
                            <div class="th-inner ">配套五金</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center;" data-field="zongjine">
                            <div class="th-inner ">总金额</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center;">
                            <div class="th-inner ">通知单</div>
                            <div class="fht-cell"></div>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="tableBody2"></tbody>
                </table>
            </div>
        </div>
        <div class="box3" th:if="${session.quanxian == '跟单'}">
            <!--            <div class="a" id="yichu" style="top: 3%;">本周已出库单据</div>-->
            <!--            <div style="position: absolute;display: flex;padding: 0 0 0 0;top: 10%;" class="col-md-12">-->
            <!--                <div class="b" style="width: 10%;text-align: center">日期</div>-->
            <!--                <div class="b" style="width: 20%;text-align: center">出库单号</div>-->
            <!--                <div class="b" style="width: 15%;text-align: center">项目名</div>-->
            <!--                <div class="b" style="width: 15%;text-align: center">商品名</div>-->
            <!--                <div class="b" style="width: 12%;text-align: center">配套五金</div>-->
            <!--                <div class="b" style="width: 12%;text-align: center">总金额</div>-->
            <!--                <div class="b" style="width: 12%;text-align: center">通知单</div>-->
            <!--            </div>-->
            <!--            <div class="i" style="height: 3px;width: 98%;top:14%;left: 1%"></div>-->
            <div id="yiChuFor" class="col-md-12 select-table table-striped"
                 style="position: absolute;top: 10%;padding: 0 0 0 0;">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th style="text-align: center;" data-field="xiadanriqi">
                            <div class="th-inner ">日期</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center;" data-field="chukudanhao">
                            <div class="th-inner ">出库单号</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center;" data-field="xiangmumingcheng">
                            <div class="th-inner ">项目名</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center;" data-field="shangpin">
                            <div class="th-inner ">商品名</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center; " data-field="wujinpeitao">
                            <div class="th-inner ">配套五金</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center;" data-field="zongjine">
                            <div class="th-inner ">总金额</div>
                            <div class="fht-cell"></div>
                        </th>
                        <th style="text-align: center;">
                            <div class="th-inner ">通知单</div>
                            <div class="fht-cell"></div>
                        </th>
                    </tr>
                    </thead>
                    <tbody id="tableBody3"></tbody>
                </table>
            </div>
        </div>
        <div class="box6" th:if="${session.quanxian == '值班'}">

            <div class="col-sm-12 select-table table-striped">
                <div class="a" style="top: 2%">未出库单据</div>
                <table id="table2main" class="table2main"></table>
            </div>
        </div>
        <div class="box5" th:if="${session.quanxian == '值班'}">
            <div class="col-md-12" style="margin-top: 15px">
                <div style="font-size: xx-large;color: #ecae0e;" class="col-md-8">
                    排班表
                </div>
                <div class="col-md-4" style="margin-top: 2.5%">
                    <button style="width: 100%;height: 100%;" class="btn btn-success" onclick="qianDao2today()">签到
                    </button>
                </div>
            </div>
            <div class="col-md-12" style="margin-top: 15px">
                <table class="PaiBanTable2main" id="paiBan2after"></table>
            </div>
        </div>
        <div class="box4 select-table table-striped">
            <table class="table table-bordered">
                <thead style="font-size: 20px">
                <tr>
                    <th style="text-align: center;" rowspan="2" colspan="1" data-field="shangpinguigekuan">
                        <div class="th-inner ">商品规格宽</div>
                        <div class="fht-cell"></div>
                    </th>
                    <th style="text-align: center; " rowspan="2" colspan="1" data-field="shangpinguigegao">
                        <div class="th-inner ">商品规格高</div>
                        <div class="fht-cell"></div>
                    </th>
                    <th style="text-align: center; " rowspan="2" colspan="1" data-field="shangpinkaixiang">
                        <div class="th-inner ">商品开向</div>
                        <div class="fht-cell"></div>
                    </th>
                    <th style="text-align: center; " rowspan="2" colspan="1" data-field="shangpinkucun">
                        <div class="th-inner ">总库存</div>
                        <div class="fht-cell"></div>
                    </th>
                    <th style="text-align: center; " rowspan="1" colspan="5">
                        <div class="th-inner ">库存详情</div>
                        <div class="fht-cell"></div>
                    </th>
                </tr>
                <tr>
                    <th style="text-align: center; " rowspan="1" colspan="1" data-field="jieCunList">
                        <div class="th-inner ">商品名称</div>
                        <div class="fht-cell"></div>
                    </th>
                    <th style="text-align: center; " rowspan="1" colspan="1" data-field="jieCunList">
                        <div class="th-inner ">生产厂商</div>

                        <div class="fht-cell"></div>
                    </th>
                    <th style="text-align: center; " rowspan="1" colspan="1" data-field="jieCunList">
                        <div class="th-inner ">商品类别</div>
                        <div class="fht-cell"></div>
                    </th>
                    <th style="text-align: center; " rowspan="1" colspan="1" data-field="jieCunList">
                        <div class="th-inner ">商品售价</div>
                        <div class="fht-cell"></div>
                    </th>
                    <th style="text-align: center; " rowspan="1" colspan="1" data-field="jieCunList">
                        <div class="th-inner ">库存数量</div>
                        <div class="fht-cell"></div>
                    </th>
                </tr>
                </thead>
                <tbody id="tableBody"></tbody>
            </table>
        </div>
    </div>
</div>
<div hidden id="quanxian" th:value="${session.quanxian}"></div>
<!--<div hidden id="quanxiantest" th:object="${quanxiantest}"></div>-->
<div hidden id="weiZhiXing" th:value="${session.weiZhiXing}"></div>
<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/ruoyi/js/ry-ui.js}"></script>
<script th:src="@{/ruoyi/js/common.js}"></script>
<script type="text/javascript">
    function qianDao2today() {
        $.ajax({
            type: "post",
            datatype: "string",
            url: "/api/qianDao2today",
            data: {},
            async: false,//是否是异步请求
            success: function (result) {
                if (result === "签到成功") {
                    alert("签到成功")
                } else {
                    alert("今天您不值班或签到失败")
                }
            },
            error: function () {
                alert("后台响应出现问题");
            }
        });
    }

    $('#pay-qrcode').click(function () {
        var html = $(this).html();
        parent.layer.open({
            title: false,
            type: 1,
            closeBtn: false,
            shadeClose: true,
            area: ['600px', '360px'],
            content: html
        });
    });
    let bo = false
    window.addEventListener('DOMContentLoaded', (event) => {
        f()
    });

    function f() {
        var value1 = document.querySelector('div[id="weiZhiXing"]').getAttribute("value")
        //console.log(value1)
        if (Number(value1) > 0 && !bo) {
            alert("有未扫码出库的单子，请及时扫码出库")
            bo = true
        }
    }

    window.onload = function () {
        $.ajax({
            type: "post",
            datatype: "string",
            url: "/api/QuanXian",
            data: {},
            async: false,//是否是异步请求
            success: function (result) {
                if (result.shouyeyi != null) {
                    kuCunSet(result.shouyeyi.kucunguanliList)
                    benZhouXiaoLiang(result.shouyeyi.benzhoupaihang)
                    riYingYeE(result.shouyeyi.riyingyee)
                    yueYingYeE(result.shouyeyi.yueyingyee)
                    Last2XiaoShouDan(result.shouyeyi.xiaoshouReturnListForThreeDays)
                }
                if (result.shouyeer != null) {
                    // weichu();
                    // yichu();
                    weiChuKuDan(result.shouyeer.weichuku, result.shouyeer.yichuku)
                    kuCunSet(result.shouyeer.kucunguanliList)
                }
                if (result.shouyesan != null) {
                    // weiZhiXing();
                    paiBan(result.shouyesan.vpaibanList);
                    weiZhiXingChuKuDanJu(result.shouyesan.weichuku)
                    kuCunSet(result.shouyesan.kucunguanliList)
                }
                // XiaoShouSearch2KuCun()
            },
            error: function () {
                alert("后台响应出现问题");
            }
        });
    };

    function riYingYeEReSelect(value1, value2, value3) {
        let lists;
        $.ajax({
            type: "POST",
            datatype: "string",
            url: "/api/riYingYeEReSelect",
            data: {
                startDate: value1,
                endDate: value2,
                yewuyuan: value3
            },
            async: false,//是否是异步请求
            success: function (result) {
                lists = result
            },
            error: function () {
                alert("后台响应出现问题");
            }
        });
        var thesvg = document.getElementById("svgtest")
        $("#svgtest").empty();
        for (let i = 0; i < lists.length; i++) {
            var div1 = document.createElement("div")
            div1.className = "col-sm-12"
            div1.style.marginTop = "10px"

            var tr1 = document.createElement("div")
            tr1.className = "col-sm-3"
            tr1.style.textAlign = "center"
            tr1.innerHTML = lists[i].huizongriqi.split(" ")[0]

            var tr2 = document.createElement("div")
            tr2.className = "col-sm-3"
            tr2.style.textAlign = "center"
            tr2.innerHTML = lists[i].fahuoren

            var tr3 = document.createElement("div")
            tr3.className = "col-sm-2"
            tr3.style.textAlign = "center"
            tr3.innerHTML = lists[i].chengbenhuizong

            var tr4 = document.createElement("div")
            tr4.className = "col-sm-2"
            tr4.style.textAlign = "center"
            tr4.innerHTML = lists[i].maoli

            var tr5 = document.createElement("div")
            tr5.className = "col-sm-2"
            tr5.style.textAlign = "center"
            tr5.innerHTML = lists[i].yingyee

            div1.appendChild(tr1)
            div1.appendChild(tr2)
            div1.appendChild(tr3)
            div1.appendChild(tr4)
            div1.appendChild(tr5)

            thesvg.appendChild(div1)
        }
    }

    function riYingYeE(lists) {
        var thesvg = document.getElementById("svgtest")
        $("#svgtest").empty();
        for (let i = 0; i < lists.length; i++) {
            var div1 = document.createElement("div")
            div1.className = "col-sm-12"
            div1.style.marginTop = "10px"

            var tr1 = document.createElement("div")
            tr1.className = "col-sm-3"
            tr1.style.textAlign = "center"
            tr1.innerHTML = lists[i].huizongriqi.split(" ")[0]

            var tr2 = document.createElement("div")
            tr2.className = "col-sm-3"
            tr2.style.textAlign = "center"
            tr2.innerHTML = lists[i].fahuoren

            var tr3 = document.createElement("div")
            tr3.className = "col-sm-2"
            tr3.style.textAlign = "center"
            tr3.innerHTML = lists[i].chengbenhuizong

            var tr4 = document.createElement("div")
            tr4.className = "col-sm-2"
            tr4.style.textAlign = "center"
            tr4.innerHTML = lists[i].maoli

            var tr5 = document.createElement("div")
            tr5.className = "col-sm-2"
            tr5.style.textAlign = "center"
            tr5.innerHTML = lists[i].yingyee

            div1.appendChild(tr1)
            div1.appendChild(tr2)
            div1.appendChild(tr3)
            div1.appendChild(tr4)
            div1.appendChild(tr5)

            thesvg.appendChild(div1)
        }
    }

    function benZhouXiaoLiang(lists) {
        var mainSearch = document.getElementById("week2main")
        $("div[id='week2main']").empty()
        for (let i = 0; i < lists.length; i++) {
            var outside = document.createElement("div")
            outside.className = "col-md-12"
            outside.style.marginTop = "1.5%"
            outside.style.display = "flex"
            outside.style.padding = "0 0 0 0"

            var date = document.createElement("div")
            date.className = "b"
            date.style.width = "10%"
            date.style.textAlign = "center"
            date.innerHTML = lists[i].riqi.split(" ")[0].substring(0, 10)
            outside.appendChild(date)

            var danhao = document.createElement("div")
            danhao.className = "b"
            danhao.style.width = "20%"
            danhao.style.textAlign = "center"
            danhao.innerHTML = lists[i].danhao
            outside.appendChild(danhao)

            var xiangmumingcheng = document.createElement("div")
            xiangmumingcheng.className = "b"
            xiangmumingcheng.style.width = "20%"
            xiangmumingcheng.style.textAlign = "center"
            xiangmumingcheng.innerHTML = lists[i].xaingmuming
            outside.appendChild(xiangmumingcheng)

            var yewuyuan = document.createElement("div")
            yewuyuan.className = "b"
            yewuyuan.style.width = "15%"
            yewuyuan.style.textAlign = "center"
            yewuyuan.innerHTML = lists[i].yewuyuan
            outside.appendChild(yewuyuan)

            var faNameAndShu = document.createElement("div")
            faNameAndShu.className = "b"
            faNameAndShu.style.width = "32%"

            for (let j = 0; j < lists[i].shangpinming.length; j++) {

                var oneRow = document.createElement("div")
                oneRow.className = "b"
                oneRow.style.width = "100%"
                oneRow.style.textAlign = "center"
                oneRow.style.display = "flex"


                var Chanpinming = document.createElement("div")
                Chanpinming.className = "b"
                Chanpinming.style.width = "62.5%"
                Chanpinming.style.textAlign = "center"
                Chanpinming.innerHTML = lists[i].shangpinming[j]
                oneRow.appendChild(Chanpinming)

                var shuliang = document.createElement("div")
                shuliang.className = "b"
                shuliang.style.width = "37.5%"
                shuliang.style.textAlign = "center"
                shuliang.innerHTML = lists[i].shuliang[j]
                oneRow.appendChild(shuliang)

                faNameAndShu.appendChild(oneRow)
            }
            outside.appendChild(faNameAndShu)
            mainSearch.appendChild(outside)
        }
    }

    function Last2XiaoShouDan(lists) {
        var mainSearch = document.getElementById("last2xiaoshou")
        $("div[id='last2xiaoshou']").empty()
        for (let i = 0; i < lists.length; i++) {
            var outside = document.createElement("div")
            outside.className = "col-md-12"
            outside.style.marginTop = "1.5%"
            outside.style.display = "flex"
            outside.style.padding = "0 0 0 0"

            var date = document.createElement("div")
            date.className = "b"
            date.style.width = "10%"
            date.style.textAlign = "center"
            date.innerHTML = lists[i].xiadanriqi.split(" ")[0].substring(5)
            outside.appendChild(date)

            var danhao = document.createElement("div")
            danhao.className = "b"
            danhao.style.width = "20%"
            danhao.style.textAlign = "center"
            danhao.innerHTML = lists[i].chukudanhao
            outside.appendChild(danhao)

            var xiangmumingcheng = document.createElement("div")
            xiangmumingcheng.className = "b"
            xiangmumingcheng.style.width = "20%"
            xiangmumingcheng.style.textAlign = "center"
            xiangmumingcheng.innerHTML = lists[i].xiangmumingcheng
            outside.appendChild(xiangmumingcheng)

            var yewuyuan = document.createElement("div")
            yewuyuan.className = "b"
            yewuyuan.style.width = "15%"
            yewuyuan.style.textAlign = "center"
            yewuyuan.innerHTML = lists[i].yewuyuan
            outside.appendChild(yewuyuan)

            var faNameAndShu = document.createElement("div")
            faNameAndShu.className = "b"
            faNameAndShu.style.width = "32%"

            for (let j = 0; j < lists[i].shangpin.length; j++) {

                var oneRow = document.createElement("div")
                oneRow.className = "b"
                oneRow.style.width = "100%"
                oneRow.style.textAlign = "center"
                oneRow.style.display = "flex"


                var Chanpinming = document.createElement("div")
                Chanpinming.className = "b"
                Chanpinming.style.width = "62.5%"
                Chanpinming.style.textAlign = "center"
                Chanpinming.innerHTML = lists[i].shangpin[j].shangpinming
                oneRow.appendChild(Chanpinming)

                var shuliang = document.createElement("div")
                shuliang.className = "b"
                shuliang.style.width = "37.5%"
                shuliang.style.textAlign = "center"
                shuliang.innerHTML = lists[i].shangpin[j].shangpinshuliang
                oneRow.appendChild(shuliang)

                faNameAndShu.appendChild(oneRow)
            }
            outside.appendChild(faNameAndShu)

            var chuku = document.createElement("div")
            chuku.className = "b"
            chuku.style.width = "16%"
            chuku.style.textAlign = "center"
            chuku.innerHTML = lists[i].chuku == 0 ? "未出库" : "已出库"
            outside.appendChild(chuku)

            mainSearch.appendChild(outside)
        }
    }

    function yueYingYeE(lists) {
        var mainSearch = document.getElementById("TheToMonth")
        var div1 = document.createElement("div")
        div1.className = "col-md-3"
        div1.style.textAlign = "center"
        div1.style.fontSize = "25px"
        div1.style.padding = "2% 0 0 0"
        div1.style.color = "black"
        div1.innerHTML = "成本：" + (lists[0] != undefined ? lists[0].chengben : "0")
        mainSearch.appendChild(div1)

        div1 = document.createElement("div")
        div1.className = "col-md-3"
        div1.style.textAlign = "center"
        div1.style.fontSize = "25px"
        div1.style.padding = "2% 0 0 0"
        div1.style.color = "black"
        div1.innerHTML = "毛利：" + (lists[0] != undefined ? lists[0].maoli : "0")
        mainSearch.appendChild(div1)

        div1 = document.createElement("div")
        div1.className = "col-md-4"
        div1.style.textAlign = "center"
        div1.style.fontSize = "25px"
        div1.style.padding = "2% 0 0 0"
        div1.style.width = "32%"
        div1.style.color = "black"
        div1.innerHTML = "营业额：" + (lists[0] != undefined ? lists[0].yingyee : "0")
        mainSearch.appendChild(div1)
    }

    function kuCunSet(lists) {
        var mainSearch = document.getElementById("tableBody")
        mainSearch.style.fontSize = "20px"
        $("tbody[id='tableBody']").empty()
        var tr, td1, td2, td3, td4, td5, td6, td7, td8, td9

        for (let i = 0; i < lists.length; i++) {
            var element = lists[i]

            tr = document.createElement("tr")
            tr.dataIndex = i

            td1 = document.createElement("td")
            td1.style.fontSize = "20px"
            td1.style.textAlign = "center"
            td1.innerHTML = element.shangpinguigekuan
            tr.append(td1)

            td2 = document.createElement("td")
            td2.style.fontSize = "20px"
            td2.style.textAlign = "center"
            td2.innerHTML = element.shangpinguigegao
            tr.append(td2)

            td3 = document.createElement("td")
            td3.style.fontSize = "20px"
            td3.style.textAlign = "center"
            td3.innerHTML = element.shangpinkaixiang
            tr.append(td3)

            td4 = document.createElement("td")
            td4.style.fontSize = "20px"
            td4.style.textAlign = "center"
            td4.innerHTML = element.shangpinkucun
            tr.append(td4)

            let td4str1 = "", td4str2 = "", td4str3 = "", td4str4 = "", td4str5 = "";
            for (let j = 0; j < element.jieCunList.length; j++) {
                var danElement = element.jieCunList[j]
                var str = danElement.shangpinleibie
                if (str.indexOf("（") !== -1) {
                    str = str.substring(str.indexOf("（") + 1, str.length - 1)
                }
                if (j !== element.jieCunList.length - 1) {
                    td4str1 += danElement.shangpinming + "<br>"
                    td4str2 += danElement.shengchanchangshang + "<br>"
                    td4str3 += (str + "<br>")
                    td4str4 += danElement.shangpinshoujia + "<br>"
                    td4str5 += danElement.kucunshuliang + "<br>"
                } else {
                    td4str1 += danElement.shangpinming
                    td4str2 += danElement.shengchanchangshang
                    td4str3 += (str)
                    td4str4 += danElement.shangpinshoujia
                    td4str5 += danElement.kucunshuliang
                }
            }

            td5 = document.createElement("td")
            td5.style.fontSize = "20px"
            td5.style.textAlign = "center"
            td5.innerHTML = td4str1
            tr.append(td5)

            td6 = document.createElement("td")
            td6.style.fontSize = "20px"
            td6.style.textAlign = "center"
            td6.innerHTML = td4str2
            tr.append(td6)

            td7 = document.createElement("td")
            td7.style.fontSize = "20px"
            td7.style.textAlign = "center"
            td7.innerHTML = td4str3
            tr.append(td7)

            td8 = document.createElement("td")
            td8.style.fontSize = "20px"
            td8.style.textAlign = "center"
            td8.innerHTML = td4str4
            tr.append(td8)

            td9 = document.createElement("td")
            td9.style.fontSize = "20px"
            td9.style.textAlign = "center"
            td9.innerHTML = td4str5
            tr.append(td9)

            mainSearch.append(tr)
        }
    }

    function tupianClick(danhao,id) {
        console.log(id)
        $.ajax({
            type: "POST",
            datatype: "string",
            url: "/api/chukudanGet",
            data: {"danhao": danhao,"id": id},
            async: false,
            success: function (result) {
                console.log(result)
                if (result !== null) {
                    sessionStorage.setItem("danhao", result)
                    $.modal.open("出库单", "/api/chukudan", 1000, 800)
                }
            }
        });
    }

    function weiChuKuDan(lists, lists2) {
        // var mainSearch = document.getElementById("weiChuFor")
        // for (let i = 0; i < lists.length; i++) {
        //     var outside = document.createElement("div")
        //     outside.className = "col-md-12"
        //     outside.style.marginTop = "1.5%"
        //     outside.style.display = "flex"
        //     outside.style.padding = "0 0 0 0"
        //
        //     var date = document.createElement("div")
        //     date.className = "b"
        //     date.style.width = "11%"
        //     date.style.textAlign = "center"
        //     date.innerHTML = lists[i].xiadanriqi.substring(0, 10)
        //     outside.appendChild(date)
        //
        //     var danhao = document.createElement("div")
        //     danhao.className = "b"
        //     danhao.style.width = "20%"
        //     danhao.style.textAlign = "center"
        //     danhao.innerHTML = lists[i].chukudanhao
        //     outside.appendChild(danhao)
        //
        //     var xiangmumingcheng = document.createElement("div")
        //     xiangmumingcheng.className = "b"
        //     xiangmumingcheng.style.width = "15%"
        //     xiangmumingcheng.style.textAlign = "center"
        //     xiangmumingcheng.innerHTML = lists[i].xiangmumingcheng
        //     outside.appendChild(xiangmumingcheng)
        //
        //     var yewuyuan = document.createElement("div")
        //     yewuyuan.className = "b"
        //     yewuyuan.style.width = "15%"
        //     yewuyuan.style.textAlign = "center"
        //     for (let j = 0; j < lists[i].shangpin.length; j++) {
        //         var name = document.createElement("div")
        //         name.className = "b"
        //         name.style.textAlign = "center"
        //         name.innerHTML = lists[i].shangpin[j].shangpinming
        //         yewuyuan.appendChild(name)
        //     }
        //     outside.appendChild(yewuyuan)
        //
        //     var Chanpinming = document.createElement("div")
        //     Chanpinming.className = "b"
        //     Chanpinming.style.width = "12%"
        //     Chanpinming.style.textAlign = "center"
        //     Chanpinming.innerHTML = lists[i].wujinpeitao
        //     outside.appendChild(Chanpinming)
        //
        //     var shuliang = document.createElement("div")
        //     shuliang.className = "b"
        //     shuliang.style.width = "12%"
        //     shuliang.style.textAlign = "center"
        //     shuliang.innerHTML = lists[i].zongjine
        //     outside.appendChild(shuliang)
        //
        //     var tuPian = document.createElement("div")
        //     tuPian.className = "b"
        //     // tuPian.style.width = "10%"
        //     // tuPian.style.textAlign = "center"
        //     // tuPian.onclick = tupianClick(lists[i].id)
        //     // tuPian.style.fontSize = "12px"
        //     // tuPian.innerHTML
        //     var tupiana = document.createElement("button")
        //     tupiana.className = "btn btn-success"
        //     tupiana.style.marginTop = "-5px"
        //     tupiana.innerText = "出库通知单"
        //     // tupiana.onclick = tupianClick(lists[i].id)
        //     tupiana.setAttribute("onclick", "tupianClick('" + lists[i].chukudanhao.toString() + "')")
        //     tuPian.appendChild(tupiana)
        //     outside.appendChild(tuPian)
        //     mainSearch.appendChild(outside)
        // }
        //
        // mainSearch = document.getElementById("yiChuFor")
        // for (let i = 0; i < lists2.length; i++) {
        //     outside = document.createElement("div")
        //     outside.className = "col-md-12"
        //     outside.style.marginTop = "1.5%"
        //     outside.style.display = "flex"
        //     outside.style.padding = "0 0 0 0"
        //
        //     date = document.createElement("div")
        //     date.className = "b"
        //     date.style.width = "11%"
        //     date.style.textAlign = "center"
        //     date.innerHTML = lists2[i].xiadanriqi.substring(0, 10)
        //     outside.appendChild(date)
        //
        //     danhao = document.createElement("div")
        //     danhao.className = "b"
        //     danhao.style.width = "20%"
        //     danhao.style.textAlign = "center"
        //     danhao.innerHTML = lists2[i].chukudanhao
        //     outside.appendChild(danhao)
        //
        //     xiangmumingcheng = document.createElement("div")
        //     xiangmumingcheng.className = "b"
        //     xiangmumingcheng.style.width = "15%"
        //     xiangmumingcheng.style.textAlign = "center"
        //     xiangmumingcheng.innerHTML = lists2[i].xiangmumingcheng
        //     outside.appendChild(xiangmumingcheng)
        //
        //     yewuyuan = document.createElement("div")
        //     yewuyuan.className = "b"
        //     yewuyuan.style.width = "15%"
        //     yewuyuan.style.textAlign = "center"
        //     for (let j = 0; j < lists2[i].shangpin.length; j++) {
        //         name = document.createElement("div")
        //         name.className = "b"
        //         name.style.textAlign = "center"
        //         name.innerHTML = lists2[i].shangpin[j].shangpinming
        //         yewuyuan.appendChild(name)
        //     }
        //     outside.appendChild(yewuyuan)
        //
        //     Chanpinming = document.createElement("div")
        //     Chanpinming.className = "b"
        //     Chanpinming.style.width = "12%"
        //     Chanpinming.style.textAlign = "center"
        //     Chanpinming.innerHTML = lists2[i].wujinpeitao
        //     outside.appendChild(Chanpinming)
        //
        //     shuliang = document.createElement("div")
        //     shuliang.className = "b"
        //     shuliang.style.width = "12%"
        //     shuliang.style.textAlign = "center"
        //     shuliang.innerHTML = lists2[i].zongjine
        //     outside.appendChild(shuliang)
        //
        //     tuPian = document.createElement("div")
        //     tuPian.className = "b"
        //     // tuPian.style.width = "10%"
        //     // tuPian.style.textAlign = "center"
        //     // tuPian.onclick = tupianClick(lists[i].id)
        //     // tuPian.style.fontSize = "12px"
        //     // tuPian.innerHTML
        //     tupiana = document.createElement("button")
        //     tupiana.className = "btn btn-success"
        //     tupiana.style.marginTop = "-5px"
        //     tupiana.innerText = "出库通知单"
        //     // tupiana.onclick = tupianClick(lists[i].id)
        //     tupiana.setAttribute("onclick", "tupianClick('" + lists2[i].chukudanhao + "')")
        //     tuPian.appendChild(tupiana)
        //     outside.appendChild(tuPian)
        //     mainSearch.appendChild(outside)
        // }
        var mainSearch = document.getElementById("tableBody2")
        var tr, element, td1, td2, td3, td4, td5, td6, str, td7, tuPian, tupiana, shangpin
        for (let i = 0; i < lists.length; i++) {
            tr = document.createElement("tr")
            element = lists[i]
            //    日期
            td1 = document.createElement("td")
            td1.style.textAlign = "center"
            td1.innerHTML = element.xiadanriqi.substring(" ")
            tr.append(td1)
            //     出库单号
            td2 = document.createElement("td")
            td2.style.textAlign = "center"
            td2.innerHTML = element.chukudanhao
            tr.append(td2)
            //     项目名
            td3 = document.createElement("td")
            td3.style.textAlign = "center"
            td3.innerHTML = element.xiangmumingcheng
            tr.append(td3)
            //     商品名
            td4 = document.createElement("td")
            td4.style.textAlign = "center"
            str = ""
            for (let j = 0; j < element.shangpin.length; j++) {
                shangpin = element.shangpin[j]
                if (shangpin.shangpinleibie.indexOf("扇") !== -1) {
                    if (j !== element.shangpin.length - 1) {
                        str += shangpin.shangpinming + "<br>"
                    } else {
                        str += shangpin.shangpinming
                    }
                }
            }
            td4.innerHTML = str
            tr.append(td4)
            //     配套五金
            td5 = document.createElement("td")
            td5.style.textAlign = "center"
            td5.innerHTML = element.wujinpeitao
            tr.append(td5)
            //     总金额
            td6 = document.createElement("td")
            td6.style.textAlign = "center"
            td6.innerHTML = element.zongjine
            tr.append(td6)
            //     通知单
            td7 = document.createElement("td")
            tuPian = document.createElement("div")
            tuPian.className = "b"
            tupiana = document.createElement("button")
            tupiana.className = "btn btn-success"
            tupiana.style.marginTop = "-5px"
            tupiana.innerText = "出库通知单"
            tupiana.setAttribute("onclick", "tupianClick('" + element.chukudanhao.toString()+"','"+ element.id.toString() + "')")
            tuPian.appendChild(tupiana)
            td7.append(tuPian)
            tr.append(td7)
            mainSearch.append(tr)
        }

        mainSearch = document.getElementById("tableBody3")
        for (let i = 0; i < lists2.length; i++) {
            tr = document.createElement("tr")
            element = lists2[i]
            //    日期
            td1 = document.createElement("td")
            td1.style.textAlign = "center"
            td1.innerHTML = element.xiadanriqi.substring(" ")
            tr.append(td1)
            //     出库单号
            td2 = document.createElement("td")
            td2.style.textAlign = "center"
            td2.innerHTML = element.chukudanhao
            tr.append(td2)
            //     项目名
            td3 = document.createElement("td")
            td3.style.textAlign = "center"
            td3.innerHTML = element.xiangmumingcheng
            tr.append(td3)
            //     商品名
            td4 = document.createElement("td")
            td4.style.textAlign = "center"
            str = ""
            for (let j = 0; j < element.shangpin.length; j++) {
                shangpin = element.shangpin[j]
                if (shangpin.shangpinleibie.indexOf("扇") !== -1) {
                    if (j !== element.shangpin.length - 1) {
                        str += shangpin.shangpinming + "<br>"
                    } else {
                        str += shangpin.shangpinming
                    }
                }
            }
            td4.innerHTML = str
            tr.append(td4)
            //     配套五金
            td5 = document.createElement("td")
            td5.style.textAlign = "center"
            td5.innerHTML = element.wujinpeitao
            tr.append(td5)
            //     总金额
            td6 = document.createElement("td")
            td6.style.textAlign = "center"
            td6.innerHTML = element.zongjine
            tr.append(td6)
            //     通知单
            td7 = document.createElement("td")
            tuPian = document.createElement("div")
            tuPian.className = "b"
            tupiana = document.createElement("button")
            tupiana.className = "btn btn-success"
            tupiana.style.marginTop = "-5px"
            tupiana.innerText = "出库通知单"
            tupiana.setAttribute("onclick", "tupianClick('" + element.chukudanhao.toString()+"','"+ element.id.toString() + "')")
            tuPian.appendChild(tupiana)
            td7.append(tuPian)
            tr.append(td7)
            mainSearch.append(tr)
        }
    }

    function weiZhiXingChuKuDanJu(lists) {
        var mainSearch = document.getElementById("table2main")
        var tr2th = document.createElement("tr")
        var th1 = document.createElement("th")
        th1.innerHTML = "发货通知单"
        tr2th.appendChild(th1)

        var th3 = document.createElement("th")
        th3.innerHTML = "发货单号"
        tr2th.appendChild(th3)

        var th4 = document.createElement("th")
        th4.innerHTML = "销售日期"
        tr2th.appendChild(th4)

        var th5 = document.createElement("th")
        th5.innerHTML = "项目名称"
        tr2th.appendChild(th5)

        var th7 = document.createElement("th")
        th7.innerHTML = "发货人"
        tr2th.appendChild(th7)

        var th8 = document.createElement("th")
        th8.innerHTML = "五金配套"
        tr2th.appendChild(th8)

        var th9 = document.createElement("th")
        th9.innerHTML = "商品"
        tr2th.appendChild(th9)

        // var th10 = document.createElement("th")
        // th10.innerHTML = "规格和开向"
        // tr2th.appendChild(th10)
        //
        // var th11 = document.createElement("th")
        // th11.innerHTML = "门扇数量"
        // tr2th.appendChild(th11)
        //
        // var th12 = document.createElement("th")
        // th12.innerHTML = "右门扇数量"
        // tr2th.appendChild(th12)
        //
        // var th13 = document.createElement("th")
        // th13.innerHTML = "门框数量"
        // tr2th.appendChild(th13)
        //
        // var th14 = document.createElement("th")
        // th14.innerHTML = "防火锁数"
        // tr2th.appendChild(th14)
        //
        // var th15 = document.createElement("th")
        // th15.innerHTML = "闭门器数"
        // tr2th.appendChild(th15)
        //
        // var th16 = document.createElement("th")
        // th16.innerHTML = "拉爆盖数"
        // tr2th.appendChild(th16)
        //
        var th17 = document.createElement("th")
        th17.innerHTML = "备注"
        tr2th.appendChild(th17)

        var th6 = document.createElement("th")
        th6.innerHTML = "业务员"
        tr2th.appendChild(th6)

        var th18 = document.createElement("th")
        th18.innerHTML = "销售金额"
        tr2th.appendChild(th18)

        // var th19 = document.createElement("th")
        // th19.innerHTML = "整单出库"
        // tr2th.appendChild(th19)

        mainSearch.appendChild(tr2th)

        for (let i = 0; i < lists.length; i++) {
            var tr = document.createElement("tr")

            var td1 = document.createElement("td")
            var tda = document.createElement("a")
            tda.className = "btn btn-success btn-xs"
            tda.setAttribute("onclick", "tupianClick('" + lists[i].chukudanhao + "')")
            var tdai = document.createElement("i")
            tdai.className = "fa fa-plus"
            tda.appendChild(tdai)
            tda.innerHTML = "出库通知单"
            td1.appendChild(tda)
            tr.appendChild(td1)

            var fahuoDanhao = document.createElement("td")
            fahuoDanhao.innerHTML = lists[i].chukudanhao
            tr.appendChild(fahuoDanhao)

            var chukuDate = document.createElement("td")
            chukuDate.innerHTML = lists[i].xiadanriqi
            tr.appendChild(chukuDate)

            var xiangmuName = document.createElement("td")
            xiangmuName.innerHTML = lists[i].xiangmumingcheng
            tr.appendChild(xiangmuName)

            var fahuoRen = document.createElement("td")
            fahuoRen.innerHTML = lists[i].fahuoren
            tr.appendChild(fahuoRen)

            var peitao1 = document.createElement("td")
            peitao1.innerHTML = lists[i].wujinpeitao
            tr.appendChild(peitao1)

            var goodNameMen1 = document.createElement("td")
            var mingzi = document.createElement("div")
            for (let j = 0; j < lists[i].shangpin.length; j++) {

            }
            tr.appendChild(goodNameMen1)

            var beizhu1 = document.createElement("td")
            beizhu1.innerHTML = lists[i].beizhu
            tr.appendChild(beizhu1)

            var xiangmuMen = document.createElement("td")
            xiangmuMen.innerHTML = lists[i].yewuyuan
            tr.appendChild(xiangmuMen)

            var zhonjine = document.createElement("td")
            zhonjine.innerHTML = lists[i].zongjine
            tr.appendChild(zhonjine)

            // var td2 = document.createElement("td")
            // var td2a = document.createElement("a")
            // td2a.className = "btn btn-success btn-xs"
            // td2a.setAttribute("onclick","SomeOneSaoMa("+ lists[i].id +")")
            // var td2ai = document.createElement("i")
            // td2ai.className = "fa fa-plus"
            // td2a.appendChild(td2ai)
            // td2a.innerHTML = "整单出库"
            // td2.appendChild(td2a)
            // tr.appendChild(td2)

            mainSearch.appendChild(tr)
        }
    }

    function paiBan(lists) {
        var mainSearch = document.getElementById("paiBan2after")

        var tr2th = document.createElement("tr")
        var th1 = document.createElement("th")
        th1.innerHTML = "排班日期"
        tr2th.appendChild(th1)

        var th2 = document.createElement("th")
        th2.innerHTML = "班次"
        tr2th.appendChild(th2)

        var th3 = document.createElement("th")
        th3.innerHTML = "值班人员"
        tr2th.appendChild(th3)

        var th4 = document.createElement("th")
        th4.innerHTML = "是否已签到"
        tr2th.appendChild(th4)

        mainSearch.appendChild(tr2th)
        for (let i = 0; i < lists.length; i++) {
            var tr = document.createElement("tr")

            var date = document.createElement("td")
            date.innerHTML = lists[i].paibanshijian
            tr.appendChild(date)

            var banci = document.createElement("td")
            banci.innerHTML = lists[i].banci
            tr.appendChild(banci)

            var yuangongName = document.createElement("td")
            yuangongName.innerHTML = lists[i].username
            tr.appendChild(yuangongName)

            var shifouqiandao = document.createElement("td")
            shifouqiandao.innerHTML = lists[i].shifouqiandao
            tr.appendChild(shifouqiandao)

            mainSearch.appendChild(tr)
        }
    }
</script>
</body>
</html>
